package com.alibaba.dubbo.demo.provider;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Java8TestClass implements Java8Test {

	@Override
	public void test1() {

	}
	public static void main(String[] args) {
		List<People> list=new ArrayList<>();
		People p=new People();
		p.setName("111");
		p.setPhone("222");
		People p2=new People();
		p2.setName("1112");
		p2.setPhone("222");
		list.add(p);
		list.add(p2);
		list.add(p);
		/*list.forEach(l->{
			System.out.println(l);
		});
		System.out.println(list);*/
//		System.out.println(list.stream().filter(l->l!=2).collect(Collectors.toList()));//collect(Collectors.toList())返回所有的元素
		Map<String, List<People>> map=list.stream().collect(Collectors.groupingBy(People::getPhone));//Collectors.groupingBy(People:getPhone),通过手机号分组，返回的是map
		System.out.println(list);
	}
}

 class People{
	String name;
	String phone;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
}
